package com.ml.mall.controller.dashboard;

import com.ml.mall.bean.base.ApiRestResult;
import com.ml.mall.bean.req.dashboard.DashboardDto;
import com.ml.mall.bean.req.dashboard.DashboardByPSPQueryDto;
import com.ml.mall.bean.req.delivery.DeliveryDashboardReq;
import com.ml.mall.consts.PermissionConst;
import com.ml.mall.service.dashboard.DashboardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 *   @description    :description 
 *   @author         :zxm
 *   @date           :2021/5/24
 *   @version        :1.0
**/
@Api(tags = "【dim】仪表盘相关接口")
@RestController
@RequestMapping("/dashboard")
@Slf4j
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    @ApiOperation(value = "查询管理员仪表盘")
    @PostMapping("/query_admin")
//    @RequiresPermissions(PermissionConst.DASHBOARD_QUERY_ADMIN)
    public ApiRestResult dashboardQueryAdmin(@RequestBody @Valid DashboardDto dto){
        return ApiRestResult.ok(dashboardService.queryAdminDashboard(dto));
    }

    @ApiOperation(value = "查询最近订单")
    @PostMapping("/recent_order")
//    @RequiresPermissions(PermissionConst.DASHBOARD_RECENT_ORDER)
    public ApiRestResult dashboardRecentOrder(){
        return ApiRestResult.ok(dashboardService.queryRecentOrder());
    }


    @ApiOperation(value = "查询今日物流")
    @PostMapping("/recent_delivery")
//    @RequiresPermissions(PermissionConst.DASHBOARD_RECENT_DELIVERY)
    public ApiRestResult dashboardRecentDelivery(@RequestBody DeliveryDashboardReq req){
        return ApiRestResult.ok(dashboardService.queryRecentDelivery(req));
    }

    @ApiOperation(value = "买家查询仪表盘")
    @PostMapping("/purchase/query")
//    @RequiresPermissions(PermissionConst.DASHBOARD_PURCHASE_QUERY)
    public ApiRestResult dashboardQueryPurchaser(@RequestBody @Valid DashboardByPSPQueryDto dto){
        return ApiRestResult.ok(dashboardService.queryPurchaserDashboard(dto));
    }

    @ApiOperation(value = "卖家查询仪表盘")
    @PostMapping("/supplier/query")
//    @RequiresPermissions(PermissionConst.DASHBOARD_SUPPLIER_QUERY)
    public ApiRestResult dashboardQuerySupplier(@RequestBody @Valid DashboardByPSPQueryDto dto)throws Exception{
        return ApiRestResult.ok(dashboardService.querySupplierDashboard(dto));
    }

    @ApiOperation(value = "合作商查询仪表盘")
    @PostMapping("/partner/query")
//    @RequiresPermissions(PermissionConst.DASHBOARD_PARTNER_QUERY)
    public ApiRestResult dashboardQueryPartner(@RequestBody @Valid DashboardByPSPQueryDto dto)throws Exception{
        return ApiRestResult.ok(dashboardService.queryPartnerDashboard(dto));
    }
}
